import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.heroes.weixin.Utils;
import cn.heroes.weixin.pojo.Button;
import cn.heroes.weixin.pojo.Menu;
import cn.heroes.weixin.services.IService;
import cn.heroes.weixin.services.Service;
import cn.heroes.weixin.type.ButtonType;

public class Main {
	
	private static final Logger logger = LoggerFactory.getLogger(Main.class);

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		IService service = new Service();
		List<Object> menu = service.menu();
		boolean success = Utils.createMenu(menu);
		if (success)
			logger.info("创建菜单成功");
		else
			logger.info("创建菜单失败");
	}

	public static void at() {
		System.out.println(Utils.getAccessToken());
	}

	public static void a() {
		List<Object> os = new ArrayList<Object>();

		Menu m1 = new Menu();
		m1.setName("菜单1");
		Button b3 = new Button();
		b3.setName("按钮3");
		b3.setType(ButtonType.VIEW);
		b3.setUrl("http://weixin.qq.com");
		m1.setSub_button(new Button[] { b3 });

		Button b1 = new Button();
		b1.setName("按钮1");
		b1.setType(ButtonType.VIEW);
		b1.setUrl("http://weixin.qq.com");

		Button b2 = new Button();
		b2.setName("按钮2");
		b2.setType(ButtonType.VIEW);
		b2.setUrl("http://weixin.qq.com");

		os.add(m1);
		os.add(b1);
		os.add(b2);

		System.out.println(Utils.createMenu(os));
	}
}
